<?php
namespace Home\Controller;
use Think\Controller;
class DetailsController extends CommonController {
    public function index(){
    	//分页
    	$count = M("questions")->count($questions);//查询满足要求的总记录数// 
        $Page = new \Think\Page($count,5);// 实例化分页类 传入总记录数和每页显示的记录数(5)
        $show = $Page->show();
        $this->assign('page',$show);

    	//取questions
    	$sql = 'select t1.*,t2.username,t2.headface,t3.cname from questions t1 inner join user t2 on t1.uid = t2.id inner join category t3 on t1.cid = t3.id limit '.$Page->firstRow.','.$Page->listRows;
    	$questions = M()->query($sql);
    	$this->assign('questions',$questions);
    	// var_dump($questions);
    	
    	$this->assign('class','index');
    	
    	layout('fly-tab');
    	$this->display();
    }

    public function unsolved(){
    	//分页
    	$count = M("questions")->where('status = "未结贴"')->count($questions);//查询满足要求的总记录数// 
        $Page = new \Think\Page($count,5);// 实例化分页类 传入总记录数和每页显示的记录数(5)
        $show = $Page->show();
        $this->assign('page',$show);

    	//取questions
    	$sql = 'select t1.*,t2.username,t2.headface,t3.cname from questions t1 inner join user t2 on t1.uid = t2.id inner join category t3 on t1.cid = t3.id where status = "未结贴" limit '.$Page->firstRow.','.$Page->listRows;
    	$questions = M()->query($sql);
    	$this->assign('questions',$questions);
    	// var_dump($questions);
    	
    	$this->assign('class','unsolved');

    	layout('fly-tab');
    	$this->display();
    }

    public function solved(){
    	    	//分页
    	$count = M("questions")->where('state = "已采纳"')->count($questions);//查询满足要求的总记录数// 
        $Page = new \Think\Page($count,5);// 实例化分页类 传入总记录数和每页显示的记录数(5)
        $show = $Page->show();
        $this->assign('page',$show);

    	//取questions
    	$sql = 'select t1.*,t2.username,t2.headface,t3.cname from questions t1 inner join user t2 on t1.uid = t2.id inner join category t3 on t1.cid = t3.id where status = "已采纳" limit '.$Page->firstRow.','.$Page->listRows;
    	$questions = M()->query($sql);
    	$this->assign('questions',$questions);
    	// var_dump($questions);
    	
    	$this->assign('class','solved');

    	layout('fly-tab');
    	$this->display();
    }

        public function wonderful(){
    	    	//分页
    	$count = M("questions")->where('state = "精帖" or state = "精帖,置顶" ')->count($questions);//查询满足要求的总记录数// 
        $Page = new \Think\Page($count,5);// 实例化分页类 传入总记录数和每页显示的记录数(5)
        $show = $Page->show();
        $this->assign('page',$show);

    	//取questions
    	$sql = 'select t1.*,t2.username,t2.headface,t3.cname from questions t1 inner join user t2 on t1.uid = t2.id inner join category t3 on t1.cid = t3.id where t1.state = "精帖" or t1.state = "精帖,置顶" limit '.$Page->firstRow.','.$Page->listRows;
    	$questions = M()->query($sql);
    	$this->assign('questions',$questions);
    	// var_dump($questions);
    	
    	$this->assign('class','wonderful');

    	layout('fly-tab');
    	$this->display();
    }

}